package CS4310.csueb.characters;
import CS4310.csueb.items.Armor;
import CS4310.csueb.items.Food;
import CS4310.csueb.items.Item;
import CS4310.csueb.items.KeyItem;
import CS4310.csueb.items.Shoe;
import CS4310.csueb.items.Weapon;
import CS4310.csueb.visual.CharacterSprite;
import CS4310.csueb.visual.Sprite;

/** Implementation of the abstract Character class,
 * which every interact-able character will inherit from
 * 
 * @author Bikas Satpathy
 */

public abstract class Character {
	
	private String name;
	private int level;
	private long experience;
	private int hp;
	
	private int attack;
	private int defense;
	private int speed;

	//private int stamina; //for spells or other special attacks (?)
	private Weapon equippedWeapon;
	private Armor equippedArmor;
	private Shoe equippedShoes;
	Integer allegiance; //allegiance with respect to hero whose value is null
	
	public Character(String name) {
		this.name = name;
		this.level = 1;
		this.experience = 0;
		this.hp = 100; //arbitrary number
		this.attack = this.defense = this.speed = 10; //arbitrary number
		//there is no need to use the setEquipped methods as
		//Java will default them to null
		this.allegiance = null;
		//We can give everyone generic attire to begin with like below,
		//or explicitly add each item after creation of character.
		
		//I think this notion will work for different character classes
		// i.e. Elitist(humans), Kral warrior, Folvani knight, etc
		// - Levester
		
		/*equippedWeapon = new Weapon("Pocket Knife", true, 5, 0.25);
		equippedArmor = new Armor("T-shirt", true, 5, 0.25);
		equippedShoes = new Shoe("Worn-out Nikes", true, 5, 0.25)*/

	}

	public Character(String name, int hp, int attack, int defense, int speed) {
		this.name = name;
		this.level = 1;
		this.experience = 0;
		this.hp = hp;
		this.attack = attack;
		this.defense = defense;
		this.speed = speed;
		this.allegiance = null;
	}
	
	//Return the name of the character
	public String toString() {
		return this.name;
	}
	
	//Return the level of the character
	// -Levester Chaney
	public int getLevel() {
		return this.level;
	}
	
	//Return hp of character
	public int getMaxHP() {
		return this.hp;
	}
	
	//Return the attack of the character
	public int getAttack() {
		return this.attack;
	}
	
	//Return the defense of the character
	public int getDefense() {
		return this.defense;
	}
	
	//Return the speed of the character
	public int getSpeed() {
		return this.speed;
	}
	
	//for adding atk stats when player levels up
	public void setAttack(int diff) {
		attack += diff;
	}
	
	//for adding def stats when player levels up
	public void setDefense(int diff) {
		defense += diff;
	}
	
	//for adding spd stats when player levels up
	public void setSpeed(int diff) {
		speed += diff;
	}
	
	//Return allegiance of character
	public Integer getAllegiance() {
		return this.allegiance;
	}

	//set equipped item. Check the type of passed item and set appropriate equipped item
	public void setEqiuppedItem (Item i) {
		if(i instanceof Weapon) {
			equippedWeapon = (Weapon) i;
		}
		else if(i instanceof Armor) {
			equippedArmor = (Armor) i;
		}
		else if(i instanceof Shoe) {
			equippedShoes = (Shoe) i; 
		}
	}
	
	//getters for equipped items
	public Weapon getEquippedWeapon() {
		return equippedWeapon;
	}

	public Armor getEquippedArmor() {
		return equippedArmor;
	}

	public Shoe getEquippedShoes() {
		return equippedShoes;
	}

}
